<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 常肖飞先生
  Date: 2022/5/27
  Time: 12:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户信息列表</title>
    <style>
        table{
            border: 1px solid orange;
            width: 1000px;
            margin: 10px auto;
            text-align: center;
            border-collapse: collapse;
        }
        tr{
            border: 1px solid orange;
            height: 50px;
            text-align: center;
        }
        td,th{
            border: 1px solid orange;
        }
        h2{
            text-align:center;
        }
    </style>
</head>
<body>
<h2>用户信息列表</h2>
<p>欢迎 ${uname} 来到用户信息管理系统</p>
<a href="${pageContext.request.contextPath}/user?method=logOut" >退出</a>
<table>
    <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>生日</th>
        <th>性别</th>
        <th>职业</th>
        <th>住所</th>
        <th>电话</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${List}" var="profile">
        <tr>
            <td>${profile.id}</td>
            <td>${profile.name}</td>
            <td>${profile.birthday}</td>
            <td>${profile.gender}</td>
            <td>${profile.career}</td>
            <td>${profile.address}</td>
            <td>${profile.mobile}</td>

            <td>
                <a href="/List?method=detail&profileId=${profile.id}" >明细</a>
                <a href="/update.jsp?profileId=${profile.id}" >修改</a>
            </td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="7">
            <!--  pageContext.request.contextPath可以获取到 http://localhost:8080/bookList-->
            <a href="<c:url value='/List?pageIndex=1'></c:url>">首页</a>

            <!--如果当前在第一页, 不能点击上一页-->
            <c:if test="${page.pageIndex > 1}">
                <a href="<c:url value='/List?pageIndex=${page.pageIndex - 1}'></c:url> ">上一页</a>
            </c:if>

            <!--点击下一页, 需要判断, 当前页一定小于总页数-->
            <c:if test="${page.pageIndex < page.totalPages}">
                <a href="<c:url value='/List?pageIndex=${page.pageIndex + 1 }'></c:url> ">下一页</a>
            </c:if>

            <!--点击下一页, 判断如果当前页等于总页数, 不允许点击下一页-->
            <c:if test="${page.pageIndex == page.totalPages}">
                <a>下一页</a>
            </c:if>

            <!--尾页 = 最后一页也就是总页数-->
            <a href="<c:url value='/List?pageIndex=${page.totalPages}'></c:url>">尾页</a>
        </td>
    </tr>
</table>

</body>
</html>
